<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>疾病问诊</title>
    <!-- Bootstrap -->
    <link href="../static/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="../static/css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <link href="../static/css/nprogress.css" rel="stylesheet">
    <!-- iCheck -->
    <link href="../static/css/green.css" rel="stylesheet">
    <!-- bootstrap-progressbar -->
    <link href="../static/css/bootstrap-progressbar-3.3.4.min.css" rel="stylesheet">
    <!-- JQVMap -->
    <link href="../static/css/jqvmap.min.css" rel="stylesheet" />
    <link href="../static/css/dropzone.min.css" rel="stylesheet">
    <!-- Custom Theme Style -->
    <link href="../static/css/custom.min.css"	rel="stylesheet">

    <!-- add localcss 2016-8-18 -->
    <link href='../static/localcss/appinfoadd.css' rel='stylesheet'>
    <link href='../static/localcss/appinfolist.css' rel='stylesheet'>
</head>
<body class="nav-md footer_fixed">
<div class="container body">
    <div class="main_container">
        <div class="col-md-3 left_col menu_fixed">
            <div class="left_col scroll-view">
                <div class="navbar nav_title" style="border: 0;">
                    <a href="#" class="site_title"><i class="fa fa-paw"></i> <span>APP
								BMS</span>
                    </a>
                </div>

                <div class="clearfix"></div>

                <!-- menu profile quick info -->
                <div class="profile">
                    <div class="profile_pic">
                        <img
                                src="../static/images/img.jpg"
                                alt="..." class="img-circle profile_img">
                    </div>
                    <div class="profile_info">
                        <h2><span th:text="${session.user.userName}"></span></h2>
                    </div>
                </div>
                <!-- /menu profile quick info -->

                <br />

                <!-- sidebar menu -->
                <div id="sidebar-menu"
                     class="main_menu_side hidden-print main_menu">
                    <div class="menu_section">
                        <h3><span th:text="${session.user.userName}"></span></h3>
                        <ul class="nav side-menu">
                            <li><a><i class="fa fa-home"></i> 挂号管理 <span
                                    class="fa fa-chevron-down"></span>
                            </a>
                                <ul class="nav child_menu">
                                    <li><a href="javascript:;">创建就诊卡</a>
                                    </li>
                                    <li><a href="javascript:;">门诊挂号</a>
                                    </li>
                                    <li><a href="javascript:;">挂号信息</a>
                                </ul></li>
                        </ul>
                    </div>


                </div>
                <!-- /sidebar menu -->

                <!-- /menu footer buttons -->
                <div class="sidebar-footer hidden-small">
                    <a data-toggle="tooltip" data-placement="top" title="Settings">
                        <span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
                    </a> <a data-toggle="tooltip" data-placement="top" title="FullScreen">
                    <span class="glyphicon glyphicon-fullscreen" aria-hidden="true"></span>
                </a> <a data-toggle="tooltip" data-placement="top" title="Lock"> <span
                        class="glyphicon glyphicon-eye-close" aria-hidden="true"></span>
                </a> <a data-toggle="tooltip" data-placement="top" title="Logout"
                        href="${pageContext.request.contextPath }/dev/logout"> <span
                        class="glyphicon glyphicon-off" aria-hidden="true"></span> </a>
                </div>
                <!-- /menu footer buttons -->
            </div>
        </div>

        <!-- top navigation -->
        <div class="top_nav">
            <div class="nav_menu">
                <nav>
                    <div class="nav toggle">
                        <a id="menu_toggle"><i class="fa fa-bars"></i>
                        </a>
                    </div>

                    <ul class="nav navbar-nav navbar-right">
                        <li class=""><a href="javascript:;"
                                        class="user-profile dropdown-toggle" data-toggle="dropdown"
                                        aria-expanded="false"> <img
                                src="../static/images/img.jpg"
                                alt=""><span th:text="${session.user.userName}"></span> <span
                                class=" fa fa-angle-down"></span> </a>
                            <ul class="dropdown-menu dropdown-usermenu pull-right">
                                <li><a
                                        href="/sysUser/exit"><i
                                        class="fa fa-sign-out pull-right"></i> Log Out</a>
                                </li>
                            </ul></li>

                        <li role="presentation" class="dropdown">

                            <ul id="menu1" class="dropdown-menu list-unstyled msg_list"
                                role="menu">
                                <li><a> <span class="image"><img
                                        src="../static/images/img.jpg"
                                        alt="Profile Image" />
										</span> <span> <span>John Smith</span> <span class="time">3
													mins ago</span> </span> <span class="message"> Film festivals used
												to be do-or-die moments for movie makers. They were where...
										</span> </a></li>
                                <li><a> <span class="image"><img
                                        src="../static/images/img.jpg"
                                        alt="Profile Image" />
										</span> <span> <span>John Smith</span> <span class="time">3
													mins ago</span> </span> <span class="message"> Film festivals used
												to be do-or-die moments for movie makers. They were where...
										</span> </a></li>
                                <li><a> <span class="image"><img
                                        src="../static/images/img.jpg"
                                        alt="Profile Image" />
										</span> <span> <span>John Smith</span> <span class="time">3
													mins ago</span> </span> <span class="message"> Film festivals used
												to be do-or-die moments for movie makers. They were where...
										</span> </a></li>
                                <li><a> <span class="image"><img
                                        src="../static/images/img.jpg"
                                        alt="Profile Image" />
										</span> <span> <span>John Smith</span> <span class="time">3
													mins ago</span> </span> <span class="message"> Film festivals used
												to be do-or-die moments for movie makers. They were where...
										</span> </a></li>
                                <li>
                                    <div class="text-center">
                                        <a> <strong>See All Alerts</strong> <i
                                                class="fa fa-angle-right"></i> </a>
                                    </div></li>
                            </ul></li>
                    </ul>
                </nav>
            </div>
        </div>
        <!-- /top navigation -->
        <div class="right_col" role="main">
            <div class="">

                <div class="clearfix"></div>
                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <h2>疾病问诊 </h2>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_title">
                                <h2>病人信息</h2>
                                <div class="clearfix"></div>

                            </div>

                            <div class="x_content1">
                                <div class="form-horizontal form-label-left" >
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">姓名 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input class="form-control col-md-7 col-xs-12"
                                                   type="text" readonly="readonly"  th:value="${patient.getName()}">
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name" >身份证号 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" class="form-control col-md-7 col-xs-12"
                                                   th:value="${patient.idCard}" readonly="readonly">
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">性别 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input class="form-control col-md-7 col-xs-12"
                                                   th:value="${patient.sex eq 1 ? '女':'男'}" type="text" readonly="readonly">
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">出生日期 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input class="form-control col-md-7 col-xs-12" readonly="readonly"
                                                   th:value="${patient.birthday}" type="text">
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="number">家庭住址 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text"
                                                   th:value="${patient.getAddress()}" class="form-control col-md-7 col-xs-12" readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="x_title">
                                <h2>医嘱信息</h2>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_content1">
                                <div class="form-horizontal form-label-left" >
                                    <input type="hidden" name="id" value="${appInfo.id}">
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">病人主诉 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <textarea name="chiefComplaint"  cols="15" rows="6" class="form-control col-md-7 col-xs-12"></textarea>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">诊断结果 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <textarea name="diagnosis" id="" cols="15" rows="6" class="form-control col-md-7 col-xs-12"></textarea>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <div class="col-md-6 col-md-offset-3">
                                            <button type="button" class="btn btn-success" th:onclick="|addMedicalAdvice()|">添加医嘱</button>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-md-6 col-md-offset-3">
                                            是否添加药方:<button type="button" class="btn btn-success" th:onclick="|dian()|">是</button>
                                            <button type="button" class="btn btn-success" th:onclick="|registryDown()|">否</button>
                                        </div>
                                        <div class="col-md-6 col-md-offset-3">

                                            <table border="1px" cellpadding="0" width="100%" height="100px" name="DrugList" hidden>
                                                <tr align="center">
                                                    <td><input type="button" value="新增一行+" th:onclick="|addRow()|"></td>
                                                    <td></td>
                                                    <td></td>
                                                    <td></td>
                                                    <td></td>
                                                    <td><input type="button" value="添加药方" onclick="addYaoFang()"></td>
                                                </tr >
                                                <tr align="center" >
                                                    <td>药品名称</td>
                                                    <td>药品数量</td>
                                                    <td>药品图片</td>
                                                    <td>药品单价</td>
                                                    <td>药品类型</td>
                                                    <td>操作</td>
                                                </tr>
                                            </table>
                                            <div hidden name="prescriptionDetail" >

                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-md-6 col-md-offset-3">
                                            <form action="/registry/registryDown" method="post">
                                                <input type="hidden" name="registryId" th:value="${registryId}">
                                                <input type="hidden" name="patientId" th:value="${patient.id}">
                                                <input type="hidden" name="isMedicare" th:value="${isMedicare}">
                                                <input type="hidden" name="scheduleId" th:value="${scheduleId}">
                                            <button type="submit" class="btn btn-success" >问诊结束</button>
                                            <button type="button" class="btn btn-primary" id="back" onclick="location.href='/registry/getAll';">返回</button>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- /page content -->
        <!-- footer content -->
        <footer>
            <div class="pull-right">©2016 All Rights Reserved.</div>
            <div class="clearfix"></div>
        </footer>
        <!-- /footer content -->
    </div>
</div>
<!-- jQuery -->
<script src="../static/js/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="../static/js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="../static/js/fastclick.js"></script>
<!-- NProgress -->
<script src="../static/js/nprogress.js"></script>
<!-- jQuery custom content scroller -->
<script src="../static/js/jquery.mCustomScrollbar.concat.min.js"></script>
<!-- Custom Theme Scripts -->
<script src="../static/js/custom.min.js"></script>
<!-- validator -->
<%--     <script src="../static/js/validator.js"></script> --%>
<!-- dropzone -->
<script src="../static/js/dropzone.js"></script>
<script src="/static/js/jquery-3.6.0.js"></script>
<script>

    function dian(){
        $("[name=DrugList]").show();
    }

    function addRow(){
        var str="<tr align=\"center\" width='362' height='24'>\n" +
            "<td><input type='text' size='15' name='drugName'></td>\n" +
            "<td><input type='text' size='15' name='amountList'><input type='checkbox'  checked name='ids' hidden></td>\n" +
            "<td name='img'></td>\n" +
            "<td><input type='text' size='5' name='priceList' disabled></td>\n" +
            "<td name='type'></td>\n" +
            "<td><input type='button' value='确定' onclick='queDing(this)'><input type='button' value='删除' onclick='del(this)'></td>\n" +
            "</tr >";
        $("[name=DrugList]").append(str);
    }
    function queDing(a){
        var name=$(a).parents("tr").children("td").children("[name=drugName]").val();
        var count=$(a).parents("tr").children("td").children("[name=amountList]").val();
        $.post("/drugbatch/getDrugBatch",{"name":name},
        function (data){
            var type=data.drug.type;
            var image=data.drug.image;
            var price=data.drug.price;
            $(a).parents("tr").children("td").children("[name=ids]").val(data.drugId);
            if(data!=null&&data!=""){
                $.post("/drugbatch/isCount",{"id":data.id,"count":count},
                    function (data){
                        if(data>0){
                            var b=1;
                            if(type==1){
                                b="甲类";
                            }else if(type==2){
                                b="乙类";
                            }else if(type==3){
                                b="丙类";
                            }
                            $(a).parents("tr").children("[name=img]").html(image);
                            $(a).parents("tr").children("td").children("[name=priceList]").val(price);
                            $(a).parents("tr").children("[name=type]").html(b);
                        }else{
                            $(a).parents("tr").children("td").children("[name=amountList]").val("");
                            alert("超出药品库存数量，请重新输入!!!")
                        }
                    },"text")

            }else{
                alert("没有该药品!")
                $(a).parents("tr").children("td").children("[name=drugName]").val(" ")
            }
        });
    }
    function del(a){
        $(a).parents("tr").remove();
    }

    function addMedicalAdvice(){
        if($("[name=chiefComplaint]").val()==null || $("[name=chiefComplaint]").val()==""){
            alert("病人主诉不能为空!")
        }else if($("[name=diagnosis]").val()==null || $("[name=diagnosis]").val()==""){
            alert("诊断结果不能为空!")
        }else{
            $.post("/medicalAdvice/insert",{
                "registryId":$("[name=registryId]").val(),
                "chiefComplaint":$("[name=chiefComplaint]").val(),
                "diagnosis":$("[name=diagnosis]").val()
            },function (data){
                if(data>0){
                    alert("添加医嘱成功!!!");
                }
            })
        }

    }
/*    function registryDown(){
        $.post("/registry/registryDown",
            {"registryId":$("[name=registryId]")},
        function (data){
            if(data>0){
                location.href='/registry/getAll';
            }
        },"text")
    }*/

    function addYaoFang(){
        var ids=[];
        $("[name=ids]").each(function (){
            ids.push($(this).val())
        })
        var countList=[];
        $("[name=amountList]").each(function (){
            countList.push($(this).val())
        })
        $.post("/registry/addYaoFang",{
            "registryId":$("[name=registryId]").val(),
            "drugId":$("[name=drugId]").val(),
            "patientId":$("[name=patientId]").val(),
            "isMedicare":$("[name=isMedicare]").val(),
            "idss":ids,
            "countList":countList
        },function (data){
            alert("添加药方成功!!!")
            var str="<p>该药方总金额为:"+data.fee+"</p>"+
                    "<p>医保报销金额为:"+data.medicareFee+"</p>" +
                    "<p>实际应支付金额为:"+data.payFee+"</p>";
            $("[name=prescriptionDetail]").html(str)
            $("[name=prescriptionDetail]").show();
            $("[name=DrugList]").hide();
        },"json");
    }
</script>
</body>
</html>